/**
 * 路由配置
 * @author Zeon scplay@gmail.com
 * @date 2017/8/2
 * @copyright Created by Panxsoft.
 */
import VueRouter from 'vue-router';
import { $t } from 'src/i18n';

import handleRouter from './handleRouter';


const routers = [
	{
		path: '/login',
		name: 'login',
		meta: {
			title: $t('routers.login'),
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/login/admin-views.vue')), 'admin-login');
		},
	},
	{
		path: '/cust-login',
		name: 'cust-login',
		meta: {
			title: $t('routers.customer_login'), // '客户登录',
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/login/customer-views.vue')), 'cust-login');
		},
	},
	{
		path: '/store-login',
		name: 'store-login',
		meta: {
			title: $t('routers.store_login'), // '店铺登录',
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/login/store-views.vue')), 'store-login');
		},
	},
	{
		path: '/reset-password',
		name: 'reset',
		meta: {
			title: $t('routers.reset_password'), // '重置密码',
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/reset-password/views.vue')), 'reset');
		},
	},
	// 公用的后台首页
	{
		path: '/mirror',
		meta: {
			title: $t('routers.mirror_home'), // ''后台首页',
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/index.vue')), 'mirror-views');
		},
		children: [
			// 首页
			{
				path: '/',
				name: 'mirror-home',
				meta: {
					title: $t('routers.mirror_home'), // 后台首页,
				},
				component(resolve) {
					return require.ensure([], () => resolve(require('./views/home/index.vue')), 'mirror-home');
				},
			},
			// admin权限下的路由
			{
				path: '/admin',
				name: 'admin-views',
				meta: {
					title: `${$t('routers.admin_home')} - ${$t('routers.admin')}`, // 超管后台首页,
					menu: $t('routers.admin_home'),
				},
				component(resolve) {
					return require.ensure([], () => resolve(require('./views/admin/views.vue')), 'admin-views');
				},
				children: [
					{
						path: '/',
						meta: {
							title: `${$t('routers.mirror_home')}`, // 后台首页,
							menu: $t('routers.mirror_home'),
						},
						component(resolve) {
							return require.ensure([], () => resolve(require('./views/admin/home/views.vue')), 'mirror-admin-home');
						},
					},
					{
						path: '/home',
						meta: {
							title: `${$t('routers.mirror_home')}`, // 后台首页,
							menu: $t('routers.mirror_home'),
						},
						component(resolve) {
							return require.ensure([], () => resolve(require('./views/admin/home/views.vue')), 'mirror-admin-home');
						},
					},
					{
						path: 'customer',
						name: 'admin-customer',
						meta: {
							title: `${$t('routers.customer_management')} - ${$t('routers.admin')}`, // '客户管理',
							menu: $t('routers.customer_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/customer/views.vue')), 'customer'),
					},
					{
						path: 'staff',
						name: 'admin-staff',
						meta: {
							title: `${$t('routers.staff_management')} - ${$t('routers.admin')}`, // '职员管理',
							menu: $t('routers.staff_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/staff/views.vue')), 'staff'),
					},
					{
						path: 'product',
						name: 'admin-product',
						meta: {
							title: `${$t('routers.product_list')} - ${$t('routers.admin')}`, // '产品列表'
							menu: $t('routers.product_list'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/product/views.vue')), 'product'),
					},
					{
						path: 'product-category',
						name: 'admin-product-category',
						meta: {
							title: `${$t('routers.product_category')} - ${$t('routers.admin')}`, // '产品分类'
							menu: $t('routers.product_category'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/product/category/views.vue')), 'product-category'),
					},
					{
						path: 'product-brand',
						name: 'admin-product-brand',
						meta: {
							title: `${$t('routers.product_brand')} - ${$t('routers.admin')}`, // '产品品牌'
							menu: $t('routers.product_brand'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/product/brand/views.vue')), 'admin-product-brand'),
					},
					// {
					// 	path: 'product-model',
					// 	name: 'product-model',
					// 	meta: {
					// 		title: `${$t('routers.product_model')} - ${$t('routers.admin')}`, // '产品模型',
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/model/views.vue')), 'product-model'),
					// },
					// {
					// 	path: 'product-specification',
					// 	name: 'product-specification',
					// 	meta: {
					// 		title: `${$t('routers.product_spec')} - ${$t('routers.admin')}`, // '产品规格',
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/specification/views.vue')), 'product-specification'),
					// },
					// {
					// 	path: 'product-attribute',
					// 	name: 'product-attribute',
					// 	meta: {
					// 		title: `${$t('routers.product_attribute')} - ${$t('routers.admin')}`, // '产品属性',
					// 	},
					// 	component: resolve => require.ensure([], () => resolve(require('./views/admin/product/attribute/views.vue')), 'product-attribute'),
					// },
					{
						path: 'product-tag',
						name: 'product-tag',
						meta: {
							title: `${$t('routers.product_tag')} - ${$t('routers.admin')}`, // '产品标签'
							menu: $t('routers.product_tag'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/product/tag/views.vue')), 'product-tag'),
					},
					{
						path: 'equipment',
						name: 'admin-equipment',
						meta: {
							title: `${$t('routers.add_device_management')} - ${$t('routers.admin')}`, // '新增设备管理'
							menu: $t('routers.add_device_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/equipment/views.vue')), 'equipment'),
					},
					{
						path: 'machine-parameters',
						name: 'machine-parameters',
						meta: {
							title: `${$t('routers.machine_parameters_management')} - ${$t('routers.admin')}`, // 机器试妆参数管理
							menu: $t('routers.machine_parameters_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/machine-parameters/views.vue')), 'machine-parameters'),
					},
					{
						path: 'supplies-management',
						name: 'supplies-management',
						meta: {
							title: `${$t('routers.supplies_management')} - ${$t('routers.admin')}`, // 物资管理
							menu: $t('routers.supplies_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/supplies/views.vue')), 'supplies-management'),
					},
					{
						path: 'activity-management',
						name: 'activity-management',
						meta: {
							title: `${$t('routers.activity_management')} - ${$t('routers.admin')}`, // 活动管理
							menu: $t('routers.activity_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/activity/views.vue')), 'activity-management'),
					},
					{
						path: 'test-product-label',
						name: 'test-product-label',
						meta: {
							title: `${$t('routers.product_label_management')} - ${$t('routers.admin')}`, // 检测项关联产品标签的管理
							menu: $t('routers.product_label_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/test-product-label/views.vue')), 'test-product-label'),
					},
					{
						path: 'operate-log',
						name: 'operate-log',
						meta: {
							title: `${$t('menus.operate_log')} - ${$t('routers.admin')}`, // 操作日志
							menu: $t('menus.operate_log'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/operate-log/views.vue')), 'operate-log'),
					},
					{
						path: 'account-overview',
						name: 'account-overview',
						meta: {
							title: `${$t('menus.account_overview')} - ${$t('routers.admin')}`, // 账号总览
							menu: $t('menus.account_overview'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/admin/equipment/account-overview/views.vue')), 'account-overview'),
					},
				],
			},
			// customer权限下的路由
			{
				path: '/customer',
				name: 'customer-views',
				meta: {
					title: `${$t('routers.customer_home')} - ${$t('routers.customer')}`, // 客户后台首页,
					menu: $t('routers.customer_home'),
				},
				component(resolve) {
					return require.ensure([], () => resolve(require('./views/customer/views.vue')), 'customer-views');
				},
				children: [
					{
						path: '/',
						meta: {
							title: `${$t('routers.mirror_home')}`, // 后台首页
							menu: $t('routers.mirror_home'),
						},
						component(resolve) {
							return require.ensure([], () => resolve(require('./views/home/index.vue')), 'mirror-customer-home');
						},
					},
					{
						path: 'store',
						name: 'cust-store',
						meta: {
							title: `${$t('routers.store_management')} - ${$t('routers.customer')}`, // '店铺管理'
							menu: $t('routers.store_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/store/views.vue')), 'store'),
					},
					{
						path: 'company',
						name: 'cust-company',
						meta: {
							title: `${$t('routers.company_management')} - ${$t('routers.customer')}`, // '公司管理'
							menu: $t('routers.company_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/company/views.vue')), 'company'),
					},
					{
						path: 'product',
						name: 'cust-product',
						meta: {
							title: `${$t('routers.add_product')} - ${$t('routers.customer')}`, // '产品管理'
							menu: $t('routers.add_product'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/product/views.vue')), 'product'),
					},
					{
						path: 'product-brand',
						name: 'customer-product-brand',
						meta: {
							title: `${$t('routers.product_brand')} - ${$t('routers.customer')}`, // '产品品牌'
							menu: $t('routers.product_brand'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/product/brand/views.vue')), 'product-brand'),
					},

					{
						path: 'product-category',
						name: 'customer-product-category',
						meta: {
							title: `${$t('routers.product_category')} - ${$t('routers.customer')}`, // '分类管理'
							menu: $t('routers.product_category'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/product/category/views.vue')), 'product-category'),
					},
					{
						path: 'tryon-material',
						name: 'tryon-material',
						meta: {
							title: `${$t('routers.tryon_material')} - ${$t('routers.customer')}`, // '试戴素材',
							menu: $t('routers.tryon_material'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/product/material/views.vue')), 'tryon-material'),
					},
					{
						path: 'staff',
						name: 'cust-staff',
						meta: {
							title: `${$t('routers.staff_management')} - ${$t('routers.customer')}`, // '职员管理',
							menu: $t('routers.staff_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/staff/views.vue')), 'staff'),
					},
					{
						path: 'device-account',
						name: 'customer-device-account',
						meta: {
							title: `${$t('routers.account_device')} - ${$t('routers.customer')}`, // '设备账号'
							menu: $t('routers.account_device'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/device-account/views.vue')), 'customer-device-account'),
					},
					{
						path: 'skin-test',
						name: 'customer-skin-test',
						meta: {
							title: `${$t('routers.skin_test')} - ${$t('routers.customer')}`, // '肤质检测数据'
							menu: $t('routers.skin_test'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/skin-test/views.vue')), 'customer-skin-test'),
					},
					{
						path: 'expert-suggest',
						name: 'customer-expert-suggest',
						meta: {
							title: `${$t('menus.expert_suggest')} - ${$t('routers.customer')}`, // 肤质检测建议自定义修改
							menu: $t('menus.expert_suggest'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/expert-suggest/views.vue')), 'customer-expert-suggest'),
					},
					{
						path: 'custom-recommend-value',
						name: 'customer-custom-recommend-value',
						meta: {
							title: `${$t('menus.touch_recommend_value')} - ${$t('routers.customer')}`, // 智能测肤推荐商品
							menu: $t('menus.touch_recommend_value'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/custom-recommend-value/views.vue')), 'customer-custom-recommend-value'),
					},
					{
						path: 'custom-recommend-wax',
						name: 'customer-custom-recommend-wax',
						meta: {
							title: `${$t('menus.img_recommend_value')} - ${$t('routers.customer')}`, // 3D测肤推荐商品
							menu: $t('menus.img_recommend_value'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/custom-recommend-wax/views.vue')), 'customer-custom-recommend-wax'),
					},
					{
						path: 'skin-test-detail',
						name: 'customer-skin-test-detail',
						meta: {
							title: `${$t('routers.skin_test_detail')} - ${$t('routers.customer')}`, // '肤质检测数据详情'
							menu: $t('routers.skin_test_detail'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/skin-test/detail/views.vue')), 'customer-skin-test-detail'),
					},
					{
						path: 'hair-assets',
						name: 'customer-hair-assets',
						meta: {
							title: `${$t('routers.hair_assets')} - ${$t('routers.customer')}`, // '发型素材管理'
							menu: $t('routers.hair_assets'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/hair-assets/views.vue')), 'customer-hair-assets'),
					},
					{
						path: 'overall-makeup',
						name: 'customer-overall-makeup',
						meta: {
							title: `${$t('routers.overall_makeup')} - ${$t('routers.customer')}`, // '整体妆容'
							menu: $t('routers.overall_makeup'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/overall-makeup/views.vue')), 'customer-overall-makeup'),
					},
					{
						path: 'classification',
						name: 'customer-classification',
						meta: {
							title: `${$t('routers.classify_management')} - ${$t('routers.customer')}`, // '分类管理'
							menu: $t('routers.classify_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/classification/views.vue')), 'customer-classification'),
					},
					{
						path: 'advert',
						name: 'customer-device-advert',
						meta: {
							title: `${$t('routers.advert_management')} - ${$t('routers.customer')}`, // '广告管理'
							menu: $t('routers.advert_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/advert/views.vue')), 'advert'),
					},
					{
						path: 'banner',
						name: 'customer-device-banner',
						meta: {
							title: `${$t('routers.banner_management')} - ${$t('routers.customer')}`, // 'Banner管理'
							menu: $t('routers.banner_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/banner/views.vue')), 'banner'),
					},
					{
						path: 'youzan-order',
						name: 'customer-youzan-order',
						meta: {
							title: `${$t('routers.favorable_order_management')} - ${$t('routers.customer')}`, // 有赞订单管理
							menu: $t('routers.favorable_order_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/youzan-order/views.vue')), 'customer-youzan-order'),
					},
					{
						path: 'material',
						name: 'customer-material',
						meta: {
							title: `${$t('routers.material_management')} - ${$t('routers.customer')}`, // 产品材质管理
							menu: $t('routers.material_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/material/views.vue')), 'customer-material'),
					},
					{
						path: 'brand-series',
						name: 'customer-brand-series',
						meta: {
							title: `${$t('routers.brand_series_management')} - ${$t('routers.customer')}`, // 品牌系列管理
							menu: $t('routers.brand_series_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/product/brand-series/views.vue')), 'customer-brand-series'),
					},
					{
						path: 'share-product',
						name: 'customer-share-product',
						meta: {
							title: `${$t('menus.share_product')} - ${$t('routers.customer')}`, // 品牌系列管理
							menu: $t('menus.share_product'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/product/share-product/views.vue')), 'customer-share-product'),
					},
					{
						path: 'youzan-product',
						name: 'customer-youzan-product',
						meta: {
							title: `${$t('routers.youzan_product')} - ${$t('routers.customer')}`, // 有赞产品
							menu: $t('routers.youzan_product'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/youzan-product/views.vue')), 'customer-youzan-product'),
					},
					{
						path: 'youzan-authorize',
						name: 'customer-youzan-authorize',
						meta: {
							title: `${$t('menus.youzan_authorize')} - ${$t('routers.customer')}`, // 有赞授权
							menu: $t('menus.youzan_authorize'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/customer/youzan-authorize/views.vue')), 'customer-youzan-authorize'),
					},
				],
			},
			// store权限下的路由
			{
				path: '/store',
				name: 'store-views',
				meta: {
					title: `${$t('routers.store_home')} - ${$t('routers.store')}`, // 店铺后台首页
					menu: $t('routers.store_home'),
				},
				component(resolve) {
					return require.ensure([], () => resolve(require('./views/store/views.vue')), 'store-views');
				},
				children: [
					{
						path: '/',
						meta: {
							title: `${$t('routers.mirror_home')}`, // 后台首页
							menu: $t('routers.mirror_home'),
						},
						component(resolve) {
							return require.ensure([], () => resolve(require('./views/home/index.vue')), 'mirror-store-home');
						},
					},
					{
						path: 'salesman',
						name: 'store-salesman',
						meta: {
							title: `${$t('routers.salesman')} - ${$t('routers.store')}`, // '业务员管理'
							menu: $t('routers.salesman'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/salesman/views.vue')), 'salesman'),
					},
					{
						path: 'staff',
						name: 'store-staff',
						meta: {
							title: `${$t('routers.staff_management')} - ${$t('routers.store')}`, // '职员管理'
							menu: $t('routers.staff_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/staff/views.vue')), 'staff'),
					},
					{
						path: 'product',
						name: 'store-product',
						meta: {
							title: `${$t('routers.add_product')} - ${$t('routers.store')}`, // '产品管理'
							menu: $t('routers.add_product'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/product/views.vue')), 'product'),
					},
					{
						path: 'device-account',
						name: 'store-device-account',
						meta: {
							title: `${$t('routers.account_device')} - ${$t('routers.store')}`, // '设备账号'
							menu: $t('routers.account_device'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/device-account/views.vue')), 'store-device-account'),
					},

					{
						path: 'skin-test',
						name: 'store-skin-test',
						meta: {
							title: `${$t('routers.skin_test')} - ${$t('routers.store')}`, // '肤质检测数据'
							menu: $t('routers.skin_test'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/skin-test/views.vue')), 'store-skin-test'),
					},
					{
						path: 'skin-test-detail',
						name: 'store-skin-test-detail',
						meta: {
							title: `${$t('routers.skin_test_detail')} - ${$t('routers.store')}`, // '肤质检测数据详情'
							menu: $t('routers.skin_test_detail'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/skin-test/detail/views.vue')), 'store-skin-test-detail'),
					},
					{
						path: 'overall-makeup',
						name: 'store-overall-makeup',
						meta: {
							title: `${$t('routers.overall_makeup')} - ${$t('routers.store')}`, // '整体妆容管理'
							menu: $t('routers.overall_makeup'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/overall-makeup/views.vue')), 'store-overall-makeup'),
					},
					{
						path: 'youzan-order',
						name: 'store-youzan-order',
						meta: {
							title: `${$t('routers.favorable_order_management')} - ${$t('routers.store')}`, // 有赞订单管理
							menu: $t('routers.favorable_order_management'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/youzan-order/views.vue')), 'store-youzan-order'),
					},
					{
						path: 'youzan-product',
						name: 'store-youzan-product',
						meta: {
							title: `${$t('routers.youzan_product')} - ${$t('routers.store')}`, // 有赞产品
							menu: $t('routers.youzan_product'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/youzan-product/views.vue')), 'store-youzan-product'),
					},
					{
						path: 'youzan-authorize',
						name: 'store-youzan-authorize',
						meta: {
							title: `${$t('menus.youzan_authorize')} - ${$t('routers.customer')}`, // 有赞授权
							menu: $t('menus.youzan_authorize'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/youzan-authorize/views.vue')), 'store-youzan-authorize'),
					},
					{
						path: 'custom-recommend-value',
						name: 'custom-custom-recommend-value',
						meta: {
							title: `${$t('menus.touch_recommend_value')} - ${$t('routers.store')}`, //智能测肤推荐商品
							menu: $t('menus.touch_recommend_value'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/custom-recommend-value/views.vue')), 'store-custom-recommend-value'),
					},
					{
						path: 'custom-recommend-wax',
						name: 'custom-custom-recommend-wax', //
						meta: {
							title: `${$t('menus.img_recommend_value')} - ${$t('routers.store')}`, // 3D测肤推荐商品
							menu: $t('menus.img_recommend_value'),
						},
						component: resolve => require.ensure([], () => resolve(require('./views/store/custom-recommend-wax/views.vue')), 'store-custom-recommend-wax'),
					},
				],
			},
			// 本地测试路由
			{
				path: '/v-debug',
				component(resolve) {
					return require.ensure([], () => resolve(require('./views/debug/index.vue')), 'debug-index');
				},
				children: [
					{
						path: '/',
						name: 'debug',
						meta: {
							title: 'debug测试',
						},
						component: resolve => require.ensure([], () => resolve(require('./views/debug/vuex.vue')), 'debug-vuex'),
					},
					{
						path: 'example',
						meta: {
							title: 'example测试',
						},
						component: resolve => require.ensure([], () => resolve(require('./views/debug/example.vue')), 'example'),
					},
				],
			},
		],
	},
	{
		path: '/authorize-status',
		name: 'authorize-status',
		meta: {
			title: $t('routers.auth_info'),	// 授权成功
		},
		component(resolve) {
			return require.ensure([], () => resolve(require('./views/component/authorize-status.vue')), 'authorize-status');
		},
	},
	// {
	// 	path: '*',
	// 	redirect: { name: 'mirror-home' },
	// },
];

// 路由配置
const RouterConfig = {
	// mode: 'history',
	mode: 'hash',
	routes: routers,
};

const router = new VueRouter(RouterConfig);

router.beforeEach(handleRouter.before);
router.afterEach(handleRouter.after);

export default router;
